﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Windows;
using System.Windows.Controls;
using XYAC.Framework.MonitorTireMaterialManual.Entities;
using XYAC.Framework.MonitorTireMaterialManual.Extensions;
using XYAC.Framework.MonitorTireMaterialManual.ViewModels;
using XYAC.Framework.MonitorTireMaterialManual.Views.ReadonlyView;

namespace XYAC.Framework.MonitorTireMaterialManual.Views
{
    /// <summary>
    /// QualityDataHistoryView.xaml 的交互逻辑
    /// </summary>
    public partial class QualityDataHistoryView : UserControl
    {
        public QualityDataHistoryView(IOptionsMonitor<AppConfig> options, 
            ILogger<SystemConfigView> logger,  QualityDataHistoryViewModel viewmodel, IServiceProvider provider)
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception)
            {

            }
            this.Provider = provider;
            this.AppConfig = options;
            this.DataContext = viewmodel;
            this.Logger = logger;
        }

        public IServiceProvider Provider { get; }
        public IOptionsMonitor<AppConfig> AppConfig { get; }
        public ILogger Logger { get; }
        public int HistorySelectedIndex { get; private set; }

        private void TabRecordHistory_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.DataContext is QualityDataHistoryViewModel viewmodel &&
            this.HistorySelectedIndex != this.TabRecordHistory.SelectedIndex)
            {
                viewmodel.UserSelectDataType = this.TabRecordHistory.SelectedIndex;
                this.HistorySelectedIndex = this.TabRecordHistory.SelectedIndex;
                viewmodel.RefershLocalRecords();

            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
